/*
 * @Description: 
 * @Version: 1.0
 * @Autor: c-jack.qian
 * @Date: 2021-04-22 15:20:05
 * @LastEditors: c-jack.qian
 * @LastEditTime: 2021-04-22 15:31:46
 */
import { init } from 'snabbdom/build/package/init'
import { h } from 'snabbdom/build/package/h'

// 导入模块
import { styleModule } from 'snabbdom/build/package/modules/style'
import { eventListenersModule } from 'snabbdom/build/package/modules/eventlisteners'

// 注册模块
let patch = init([styleModule, eventListenersModule])

// 使用模块
// 创建子元素，并且往子元素添加样式和事件
let vnode = h('div', [
    h('h1', {
        style: {
            color: 'red'
        }
    }, 'hello Module'),
    h('p', {
        on: {
            click: handleClick
        }
    }, '点击我呀')
])

function handleClick() {
    alert('我被点击了')
}

// 挂在到真实dom上
patch(document.querySelector('#app'), vnode)